From 71b522c2914e33534036de823864d02010cb3b37 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 22 Jul 2015 14:33:21 -0700 Subject: [PATCH] Use the download module for printing snapshots The script that prints new snapshots for Cargo now uses the same download module as the rest of Cargo. Also adds a quiet option to suppress printing. --- src/etc/download.py | 6 +++--- src/etc/print-new-snapshot.py | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/etc/download.py b/src/etc/download.py index 27d4a861f..2a6636ccf 100644 --- a/src/etc/download.py +++ b/src/etc/download.py @@ -5,14 +5,14 @@ import subprocess import sys import tarfile -def get(url, path): +def get(url, path, quiet=False): # see http://serverfault.com/questions/301128/how-to-download if sys.platform == 'win32': run(["PowerShell.exe", "/nologo", "-Command", "(New-Object System.Net.WebClient).DownloadFile('" + url + - "', '" + path + "')"]) + "', '" + path + "')"], quiet=quiet) else: - run(["curl", "-o", path, url]) + run(["curl", "-o", path, url], quiet=quiet) def unpack(tarball, dst, quiet=False): if quiet: diff --git a/src/etc/print-new-snapshot.py b/src/etc/print-new-snapshot.py index bbb106563..7f0aff538 100644 --- a/src/etc/print-new-snapshot.py +++ b/src/etc/print-new-snapshot.py @@ -3,6 +3,7 @@ import os import subprocess import sys import hashlib +import download date = sys.argv[1] @@ -24,10 +25,8 @@ snaps = { for platform in sorted(snaps): triple = snaps[platform] tarball = 'cargo-nightly-' + triple + '.tar.gz' - url = 'https://static-rust-lang-org.s3.amazonaws.com/cargo-dist/' + date + '/' + tarball + url = 'https://static.rust-lang.org/cargo-dist/' + date + '/' + tarball dl_path = "target/dl/" + tarball - ret = subprocess.call(["curl", "-f", "-s", "-o", dl_path, url]) - if ret != 0: - raise Exception("failed to fetch url") + download.get(url, dl_path, quiet = True) h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest() print(' ' + platform + ' ' + h) -- 2.30.2